// 后台管理的路由组件
import React, { Component } from 'react';
import { Navigate, Outlet } from 'react-router-dom'

import { connect } from 'react-redux'

// import memoryUtils from '../../utils/memoryUtils'

import LeftNav from '../../components/leftNav/LeftNav'
import Header from '../../components/header/Header'

import { Layout } from 'antd';
const { Footer, Sider, Content } = Layout;

class Admin extends Component {
  render () {
    const user = this.props.user
    if (!user || !user._id) {
      return <Navigate to="/login" />
    }
    return (
      <Layout style={{ minHeight: '100vh' }}>
        <Sider>
          <LeftNav></LeftNav>
        </Sider>
        <Layout style={{ overflow: "auto" }}>
          <Header>Header</Header>
          <Content style={{ backgroundColor: '#fff', margin: '20px' }}>
            <Outlet />
          </Content>
          <Footer style={{ textAlign: 'center', color: '#333' }}>推荐使用谷歌浏览器，可以获得更佳的体验</Footer>
        </Layout>
      </Layout>
    );
  }
}

export default connect(
  state => ({ user: state.user }),
  {}
)(Admin);